package com.ytkj.digitalConstruction.threads;

import java.util.concurrent.ThreadFactory;

/**
 * 自定义线程工厂
 * 
 * @author momei
 */
public class MyThreadFactory implements ThreadFactory{

	 private int counter;
	 private String prefix;
	 
	 public MyThreadFactory (String prefix) {
		 this.prefix=prefix;
		 counter=1;
	 }
	@Override
	public Thread newThread(Runnable r) {
		
		MyThread myThread=new MyThread(r,prefix+"-"+counter);
		counter++;
		return myThread;
	}

}
